#ifndef SINK_H
#define SINK_H

#include "Signal.h"
#include <vector>
#include <list>
using namespace std;
// -----------------------------------------------------------
class Sink_ToFile:public block
{
  string FileName;
  int mode; // 0 = save average,1 = save average and detailed
  int repeated;
  vector<double> time;
  vector<double> value;
  vector<double> value2;
  double t_end;
  double dt;
  int    t_idx;
  int    t_node;
  ofstream fout_avg;
  ofstream fout_detail;
public:
  enum Log_mode{
    AVERAGE_STD,
    DETAIL,
    AVERAGE
  };
  Sink_ToFile(const string FileName,const double it_end,const double idt,const int imode=0);
  ~Sink_ToFile();
  virtual void update(const double itime,const double ivalue);
  virtual void update(double sysTime);
  void reset();
};
// -----------------------------------------------------------
class Sink_ToFile_vector:public block
{
  string FileName;
  ofstream fout;

  double t_end;
  double dt;
  int    t_idx;
  int    t_node;
  int    repeated;

  // These two variables corresponds to a vector of ID indicating which outputs need to be logged.
  int* ID_outputs_to_log;
  int  num_outputs_to_log;
  vector<double> time;
  list< vector<double> > value;
  list< vector<double> >::iterator iterator_value;
  list< vector<double> > value2;
  list< vector<double> >::iterator iterator_value2;

public:
  Sink_ToFile_vector(const string FileName,const double it_end,const double idt,const int iInputDim=1,int* i_ID_outputs_to_log=NULL,const int i_num_outputs_to_log=0);
  ~Sink_ToFile_vector();
  virtual void update(double sysTime);
  virtual void reset();
};
// -----------------------------------------------------------
class Sink_ToDatabase
{
};
// -----------------------------------------------------------
#endif

